
package com.rx.mgt.service;  

import java.util.List;

import com.rx.mgt.util.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rx.mgt.dao.AdminUserDao;
import com.rx.mgt.domain.AdminUser;
import com.rx.mgt.po.UsersBo;
import com.rx.mgt.util.DateUtil;

/** 
 * ClassName:AdminUserService 
 * Function :
 * Reason   : 
 * Date     :Jan 31, 2017 1:51:08 PM 
 * @author   luolei 
 * @since    JDK 1.6
 */
@Service
public class AdminUserService {
    @Autowired
    AdminUserDao adminUserDao;
    @Transactional
    public Long getAdminUserCount(UsersBo usersBo){
        return adminUserDao.getAdminUserCount(usersBo);
    }
    @Transactional
    public AdminUser getAdminUserByPsw(AdminUser adminUser){
        return adminUserDao.getAdminUserByPsw(adminUser);
    }
    @Transactional
    public List<AdminUser> getAllAdminUser(String type){
        return adminUserDao.getAllAdminUser(type);
    }
    @Transactional
    public AdminUser get(Long id){
        return  adminUserDao.get(id);
    }
    @Transactional
    public Long saveOrUpdate(AdminUser adminUser){
        if(adminUser.getId()!=null&&adminUser.getId()>0){
            adminUserDao.update(adminUser);
            return adminUser.getId();
        }else{
            adminUser.setCreate_time(DateUtil.nowTimeString());
            adminUser.setUser_password(MD5.MD5Encode(adminUser.getUser_password()));
            return (Long) adminUserDao.save(adminUser);
        }
    }
    @Transactional
    public void update(AdminUser adminUser){
        adminUserDao.update(adminUser);
    }
    @Transactional
    public void delete(Long id){
        adminUserDao.delete(adminUserDao.get(id));
    }

    @Transactional
    public List getAdminUserNameByName(String name) {
        return adminUserDao.getAdminUserNameByName(name);
    }
}
  